<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">
        <div>
            {{getTemp}}
        </div>
        <div>
            <!-- 触发get -->
            {{aPlus}}
        </div>
        <button @click="change">修改</button>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        let vm = new Vue({
            el: "#box",
            data: {
                temp: 10,
                a: 10
            },
            computed: {
                // 计算属性
                getTemp() {
                    return this.temp * 10
                },
                // 读取和设置
                aPlus: {
                    get: function () {
                        return this.a;
                    },
                    set: function (v) {
                        this.a = v - 1
                    }
                }
            },
            methods:{
                change(){
                    this.aPlus = 10; // 触发set
                }
            }
        })
    </script>
</body>

</html>